package com.config;

import com.utils.ShopInfo;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/***
 * @author: mcq
 * Date : 2023/7/9 
 * 人を信じよ、しかしその百倍も自らを信じよ
 *
 * Desc:  
 */
@Slf4j
@Data
@Component
@ConfigurationProperties(prefix = "source")
public class SourceDataProperty {

    private String username;

    private String password;

    private String url;

    private String apiToken;

    private Map<String, String> deviceMap;


    @PostConstruct
    public void initShopInfo() {
        deviceMap.forEach((key, value)->{
            ShopInfo.deviceIds.put(key.replace("shop_",""), value);
        });
        log.info("初始化所有船的信息，数量->{}", ShopInfo.deviceIds.size());
    }
}
